#ifndef HASHINTERSECTIONBOX_H_JM_20120913
#define HASHINTERSECTIONBOX_H_JM_20120913

#include "HashActivityBox.h"

namespace jm4bbx {

	template</*class HashBoxDescriptorType,*/ class HashBoxType>
	class HashIntersectionBox : 
		public HashActivityBox</*HashBoxDescriptorType,*/ HashBoxType> {
	public:
		HashIntersectionBox(bobox::box_id_type id, bobox::box_tid_type tid, 
			bobox::request *req, const bobox::parameters &params) 
			: HashActivityBox(id, tid, req, params)	{ }
	protected:
		virtual bool synchronize() const  override { return true; };
		virtual void handleRecord(valueType value, ExtendedHashEntry& entry) override {
			std::stringstream stream;
			if (entry.second > 0) {
				--entry.second;
				stream << "intersection_box id:" << getBoxInstanceId() << "  vykona ("
					<<  entry.first.first << "," << entry.first.second 
					<< ") intersection " << value << "\n";
				std::cout << stream.str();
				stream.str(std::string());
				stream.clear();
			}
		} 

	};


	//struct IntegerHashIntersectionBoxDescriptor : public HashActivityBoxDescriptor {
	//	static const char* BOX_ID;
	//};

	//struct StringHashIntersectionBoxDescriptor : public HashActivityBoxDescriptor {
	//	static const char* BOX_ID;
	//};

	class IntegerHashIntersectionBox : 
		public HashIntersectionBox</*IntegerHashIntersectionBoxDescriptor,*/ IntegerHashBox> {
	public:
		IntegerHashIntersectionBox(bobox::box_id_type id, bobox::box_tid_type tid, 
			bobox::request *req, const bobox::parameters &params) 
			: HashIntersectionBox(id, tid, req, params)	{ }
	};

	class StringHashIntersectionBox : 
		public HashIntersectionBox</*StringHashIntersectionBoxDescriptor,*/ StringHashBox> {
	public:
		StringHashIntersectionBox(bobox::box_id_type id, bobox::box_tid_type tid, 
			bobox::request *req, const bobox::parameters &params) 
			: HashIntersectionBox(id, tid, req, params)	{ }
	};	
} // namespace jm4bbx

#endif
